<!doctype html>
<html class="no-js">
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>KRY会议室管理系统</title>
  <meta name="description" content="预定记录列表">
  <meta name="keywords" content="table">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <meta name="renderer" content="webkit">
  <meta http-equiv="Cache-Control" content="no-siteapp" />
  <link rel="icon" type="image/png" href="assets/i/favicon.png">
  <link rel="apple-touch-icon-precomposed" href="assets/i/app-icon72x72@2x.png">
  <meta name="apple-mobile-web-app-title" content="Amaze UI" />
  <link rel="stylesheet" href="assets/css/amazeui.min.css"/>
  <link rel="stylesheet" href="assets/css/admin.css">
</head>
<body>
<!--[if lte IE 9]>
<p class="browsehappy">你正在使用<strong>过时</strong>的浏览器，Amaze UI 暂不支持。 请 <a href="http://browsehappy.com/" target="_blank">升级浏览器</a>
  以获得更好的体验！</p>
<![endif]-->

<header class="am-topbar am-topbar-inverse admin-header">
  <div class="am-topbar-brand">
    <strong>KRY</strong> <small>会议室管理系统</small>
  </div>

  <button class="am-topbar-btn am-topbar-toggle am-btn am-btn-sm am-btn-success am-show-sm-only" data-am-collapse="{target: '#topbar-collapse'}"><span class="am-sr-only">导航切换</span> <span class="am-icon-bars"></span></button>

  <div class="am-collapse am-topbar-collapse" id="topbar-collapse">

    <ul class="am-nav am-nav-pills am-topbar-nav am-topbar-right admin-header-list">
      <li><a href="javascript:;"><span class="am-icon-envelope-o"></span> 收件箱 <span class="am-badge am-badge-warning">5</span></a></li>
      <li class="am-dropdown" data-am-dropdown>
        <a class="am-dropdown-toggle" data-am-dropdown-toggle href="javascript:;">
          <span class="am-icon-users"></span> 管理员 <span class="am-icon-caret-down"></span>
        </a>
        <ul class="am-dropdown-content">
          <li><a href="admin-user.html"><span class="am-icon-user"></span> 资料</a></li>
          <li><a href="#"><span class="am-icon-cog"></span> 设置</a></li>
          <li><a id="signOut1" href="javascript:void(0)"><span class="am-icon-power-off"></span> 退出</a></li>
        </ul>
      </li>
      <li class="am-hide-sm-only"><a href="javascript:;" id="admin-fullscreen"><span class="am-icon-arrows-alt"></span> <span class="admin-fullText">开启全屏</span></a></li>
    </ul>
  </div>
</header>

<div class="am-cf admin-main">
  <!-- sidebar start -->
  <div class="admin-sidebar am-offcanvas" id="admin-offcanvas">
    <div class="am-offcanvas-bar admin-offcanvas-bar">
      <ul class="am-list admin-sidebar-list">
        <li><a href="admin-index.html"><span class="am-icon-home"></span> 首页</a></li>
        <li class="admin-parent">
          <a class="am-cf" data-am-collapse="{target: '#collapse-nav'}"><span class="am-icon-file"></span> 会员<span class="am-icon-angle-right am-fr am-margin-right"></span></a>
          <ul class="am-list am-collapse admin-sidebar-sub am-in" id="collapse-nav">
            <li><a href="admin-user.html" class="am-cf"><span class="am-icon-check"></span> 个人资料<span class="am-icon-star am-fr am-margin-right admin-icon-yellow"></span></a></li>
            <li><a href="admin-gallery.html"><span class="am-icon-th"></span> 会议室浏览<span class="am-badge am-badge-secondary am-margin-right am-fr">24</span></a></li>
          </ul>
        </li>
        <li><a href="admin-table.html"><span class="am-icon-table"></span> 预定记录</a></li>
        <li><a href="admin-form.html"><span class="am-icon-pencil-square-o"></span> 预定</a></li>
        <li><a id="signOut2" href="javascript:void(0)"><span class="am-icon-sign-out"></span> 注销</a></li>
      </ul>

      <div class="am-panel am-panel-default admin-sidebar-panel">
        <div class="am-panel-bd">
          <p><span class="am-icon-bookmark"></span> 公告</p>
          <p>热爱生活，团队制胜，快学快用，超越极致。<br>—— KRY</p>
        </div>
      </div>

      
    </div>
  </div>
  <!-- sidebar end -->

  <!-- content start -->
  <div class="admin-content">
    <div class="admin-content-body">
      <div class="am-cf am-padding am-padding-bottom-0">
        <div class="am-fl am-cf"><strong class="am-text-primary am-text-lg">预定记录</strong> </div>
      </div>

      <hr>

      <div class="am-g">
      
      <!-- 
       -->
        <div class="am-u-sm-12 am-u-md-3">
          <div class="am-btn-toolbar">
            <div class="am-btn-group am-btn-group-xs">
              <button type="button" class="am-btn am-btn-default"><span class="am-icon-plus"></span> 新增</button>
              <button type="button" class="am-btn am-btn-default"><span class="am-icon-save"></span> 保存</button>
              <button type="button" class="am-btn am-btn-default"><span class="am-icon-archive"></span> 审核</button>
              <button type="button" class="am-btn am-btn-default"><span class="am-icon-trash-o"></span> 删除</button>
            </div>
          </div>
        </div>
        <span>&nbsp;</span>
        <div class="am-u-sm-12 am-u-md-2">
          <div class="am-form-group">
            <select id="roomSelectId" name="cityCode" data-am-selected="{btnSize: 'sm'}"  placeholder="城市" onchange="getRoom();">
				<option ></option>
				<option value="010">北京</option>
				<option value="028" selected>成都</option>
				<option value="0755">深圳</option>
			</select>
          </div>
        </div>
        
        <div class="am-u-sm-12 am-u-md-2">
          <div class="am-form-group">
           <select id="roomNoId" name="roomNo" data-am-selected="{btnSize: 'sm'}" placeholder="会议室" >
				<option value="-1">会议室</option>
				<option value="10028001" >硅谷</option>
				<option value="10028002" >新加坡</option>
				<option value="10028003" >伦敦</option>
				<option value="10028004" >巴黎</option>
				<!-- 
				-->
			</select>
          </div>
        </div>
        
        <div class="am-u-sm-12 am-u-md-2">
          <div class="am-form-group">
              <div class="am-form-group am-form-icon">
                  <i class="am-icon-calendar"></i>
                  <input type="text" id="bookDateId" name="bookDate" class="am-form-field" placeholder="会议日期" 
                    data-am-datepicker="{format: 'yyyy-mm-dd'}" readonly required  />
              </div>
          </div>
        </div>
        
        
        <div class="am-u-sm-12 am-u-md-2">
          <div class="am-input-group am-input-group-sm">
            <button id="queryBtnId" class="am-btn am-btn-success" type="button">查询</button>&nbsp;
            <button id="queryResetId" class="am-btn am-btn-danger" type="button">重置</button>
          </div>
        </div>
        
      </div>

      <div class="am-g">
        <div class="am-u-sm-12">
         
            <table class="am-table am-table-striped am-table-hover table-main">
              <thead>
              <tr>
                <th class="table-check"></th>
                <th class="table-id">ID</th><th class="table-title">会议室</th><th class="table-type">日期</th><th class="table-date am-hide-sm-only">开始</th><th class="table-date am-hide-sm-only">结束</th><th class="table-author am-hide-sm-only">预定人</th><th class="table-title">议题</th><th class="table-set">操作</th>
              </tr>
              </thead>
              <tbody id="tableBodyId">
              <!-- 预定记录列表  -->
              </tbody>
            </table>
            
         <form class="am-form " > <!-- am-hide -->
            <div class="am-cf">
                            共 15 条记录
              <div class="am-fr">
                <ul class="am-pagination">
                  <li class="am-disabled"><a href="#">«</a></li>
                  <li class="am-active"><a href="#">1</a></li>
                  <li><a href="#">2</a></li>
                  <li><a href="#">3</a></li>
                  <li><a href="#">4</a></li>
                  <li><a href="#">5</a></li>
                  <li><a href="#">»</a></li>
                </ul>
              </div>
            </div>
            <hr />
            <p>注：.....</p>
          </form>
          
          
        </div>

      </div>
    </div>

    <footer class="admin-content-footer">
      <hr>
      <p class="am-padding-left">© 2014 AllMobilize, Inc. Licensed under MIT license.</p>
    </footer>

  </div>
  <!-- content end -->
</div>

<a href="#" class="am-icon-btn am-icon-th-list am-show-sm-only admin-menu" data-am-offcanvas="{target: '#admin-offcanvas'}"></a>

<footer>
  <hr>
  <p class="am-padding-left">© 2014 AllMobilize, Inc. Licensed under MIT license.</p>
</footer>

<!--[if lt IE 9]>
<script src="http://libs.baidu.com/jquery/1.11.1/jquery.min.js"></script>
<script src="http://cdn.staticfile.org/modernizr/2.8.3/modernizr.js"></script>
<script src="assets/js/amazeui.ie8polyfill.min.js"></script>
<![endif]-->

<!--[if (gte IE 9)|!(IE)]><!-->
<script src="assets/js/jquery.min.js"></script>
<!--<![endif]-->
<script src="assets/js/amazeui.min.js"></script>
<script src="assets/js/app.js"></script>
</body>

<script type="text/javascript">

$(function() {
	
	function getToday(){
		   var mydate = new Date();
		   var str = "" + mydate.getFullYear() + "-";
		   if(mydate.getMonth()<9){
		      str += "0"+(mydate.getMonth()+1) + "-";
		   }else{
		     str += (mydate.getMonth()+1) + "-";
		   }
		   if(mydate.getDate()<10){
		       str += "0"+mydate.getDate() ;
		   }else{
		       str += mydate.getDate() ;
		   }
		   return str;
		  }	
	 
	var today=getToday();
	//alert(today);
	
	$.ajax({
        url: '/record/query',
        type: "POST",
        cache: false, //实际使用中请禁用缓存
        async: false,
        data:{
        	cityCode:"028",
        	bookDate:today
        },
        dataType: 'json'
      }).then(function(data) {
    	 
    	$("#tableBodyId").html("");
    	
    	var recordList=data.result;
    	
    	var trStr=getRecordListTableBody(recordList);
         //alert(trStr);
         
  		$("#tableBodyId").append(trStr);
        
      }, function() {
        alert("没有查询到数据？？？");
      });
	
	
     function getRecordListTableBody(recordList){

   	   var trStr="";
   	   var opTdStr='<div class="am-btn-toolbar"><div class="am-btn-group am-btn-group-xs"><button class="am-btn am-btn-default am-btn-xs am-text-secondary"><span class="am-icon-pencil-square-o"></span> 编辑</button><button class="am-btn am-btn-default am-btn-xs am-text-success"><span class="am-icon-archive"></span> 确认</button><button class="am-btn am-btn-default am-btn-xs am-text-danger am-hide-sm-only"><span class="am-icon-trash-o"></span> 删除</button></div></div>';
 		 for(var i in recordList){
 		    trStr=trStr+"<tr>";
 		    for (var n=1; n<=9; n++){
 		    	trStr=trStr+"<td>";
 		    	switch (n){
 		    	case 1:
 		    		 trStr=trStr+'<input type="checkbox" />';
 		    	  break;
 		    	case 2:
 		    		trStr=trStr+recordList[i].id;
 		    	  break;
 		    	case 3:
 		    		trStr=trStr+recordList[i].roomName;
 		    	  break;
 		    	case 4:
 		    		trStr=trStr+recordList[i].bookDate;
 		    	  break;
 		    	case 5:
 		    		trStr=trStr+recordList[i].startTime;
 		    	  break;
 		    	case 6:
 		    		trStr=trStr+recordList[i].endTime;
 		    	  break;
 		    	case 7:
 		    		trStr=trStr+recordList[i].booker;
 		    	  break;
 		    	case 8:
 		    		trStr=trStr+recordList[i].theme;
 		    	  break;
 		    	case 9:
 		    		trStr=trStr+opTdStr;
 		    	  break;
 		    	}
 		    	trStr=trStr+"</td>";
 		    }
 		  trStr=trStr+" </tr>"; ;
 		// alert(trStr);  
        };  
        return trStr;
     }
	
	
     //查询面板的查询按钮事件
     $("#queryBtnId").on("click",function(){
		var cityCode=$("#roomSelectId").val();
		var roomNo=$("#roomNoId").val();
		var bookDate=$("#bookDateId").val();
		//alert("The queryBtn was clicked. " + cityCode +" "+roomNo+" "+bookDate);
		var queryData=
		
		$.ajax({
	        url: '/record/query',
	        type: "POST",
	        cache: false, //实际使用中请禁用缓存
	        async: false,
	        data:{
	        	cityCode : cityCode,
	        	roomNo : roomNo,
	        	bookDate : bookDate
	        },
	        dataType: 'json'
	      }).then(function(data) {
	    	 
	    	$("#tableBodyId").html("");
	    	
	    	var recordList=data.result;
	    	
	    	var trStr=getRecordListTableBody(recordList);
	         //alert(trStr);
	         
	  		$("#tableBodyId").append(trStr);
	        
	      }, function() {
	        alert("没有查询到数据？？？");
	      });
       });
	
	

})

//获取可用会议室
function getRoom(){
	 	var cityCode=$('#roomSelectId').val();
	 	$.ajax({
	         url: '/meetingroom/list',
	         type: "POST",
	         cache: false, //实际使用中请禁用缓存
	         async: false,
	         data:{
	         	cityCode : cityCode
	         },
	         dataType: 'json'
	       }).then(function(data) {
	     	 
	     	 var roomList=data.result;
	     	$("#roomNoId").html("");
	     	 var optionStr="<option value='-1'>会议室</option>";
	   		 for(var i in roomList){
	   		    optionStr+="<option value='"+roomList[i].roomNo+"'>"+roomList[i].roomName+"</option>" ;
	          };  
	   		   $("#roomNoId").append(optionStr);
	       }, function() {
	         alert("没有查询到数据？？？");
	       });
	 	
}	

</script>

</html>
